<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return['params']=array();
if($_RQ['op']=='main'){
	$return['params']=array('page'=>1,'type'=>0);
	//补充
	$category=pdo_getall('jy_help_group',array('uniacid'=>$_SESSION['uniacid'],'status'=>1),'','id','paixu desc');
	$return['category']=$category;
	$return['params']['group_id']='0';
	$sharelink='jy_help/index//&fromuser='.$_SESSION['uid'];
	$return['sharedata']=array(
			'title'=>$return['pluginset']['share_title']?:'帮助中心',
			'desc'=>$return['pluginset']['share_desc']?:'帮助中心描述',
			'link'=>custom_url($sharelink,true),
			'imgUrl'=>tomedia($return['pluginset']['share_image'])
	);
	set_html('title',$return['pluginset']['title']?:'帮助中心');
	exi($return);
}
if($_RQ['op']=='list'){
	$params=array('uniacid'=>$_SESSION['uniacid'],'status'=>1);
	if(trim($_RQ['keyword'])){
		$params['title like']='%'.trim($_RQ['keyword']).'%';
		$return['params']['keyword']=trim($_RQ['keyword']);
	}
	if($_RQ['group_id']){
		$params['group_id']=intval($_RQ['group_id']);
		$return['params']['group_id']=intval($_RQ['group_id']);
	}
	if($_RQ['keyword']){		
		$params['title like']='%'.trim($_RQ['keyword']).'%';
		$return['params']['title']=$_RQ['keyword'];	
	}
		//进一步整理筛选条件，商品属性字段是否需 要调整，商品分类如何筛选，orderby如何整理
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	if($_RQ['num']){
		$psize=$_RQ['num'];
	}
	$total='';
	$orderby='paixu desc, readnum desc, id desc ';
	$parameter=array(
		'params'=>$params,
		'limit'=>array($pindex,$psize),
		'fields'=>$fields,
		'orderby'=>$orderby,
	);
	$list=pdo_getlist('jy_help_list',$parameter);
	if(!$list){
		exi('none');
	}
	if($list){
		foreach($list as &$itemv){
			$itemv['createtime']=date('Y-m-d',$itemv['createtime']);
		}
	}
	exi($list);
}
if($_RQ['op']=='like'){
	$postdata=get_postdata();
	$id=$postdata['id'];
	if(!$id){
		exi('没有找到该问题，请重新选择！','error');
	}
	pdo_update('jy_help_list',array('likenum +='=>1),array('uniacid'=>$_SESSION['uniacid'],'id'=>$id));
	exi('点赞成功！');
}
?>